import { UIBackTopAction, UICoverAction } from "./BaseTypes";
import { uiMgr } from "./UIMgr";

/** 
 * 为类绑定一个代理(类装饰器)
 */
export const uiparams = (layer: number, rules?: { cover?: UICoverAction, backTop?: UIBackTopAction }) => {
    return (wndCtor: any) => {
        const proxyName = wndCtor.name;
        const meta = uiMgr.uiMetaMap.get(proxyName);
        if (meta) {
            console.warn(`bind------${proxyName}有重复绑定`);
            return;
        }
        uiMgr.uiMetaMap.set(proxyName,
            {
                layer,
                cover: rules?.cover ?? UICoverAction.HIDE,
                backTop: rules?.backTop ?? UIBackTopAction.SHOW,
            });
    }
}